# coding: utf-8
# author: t_wolf

from framework import *

# 渲染页面模板
web.config.render = web.template.render(CONFIGS.BASE.pages_path)

# 创建Application
app = web.application(URL_MAP, globals())

# 会话传送
if CONFIGS.SESSION.open and web.ctx.get('session') is None:
    session = SESSION(app).init()
    app.add_processor(
        web.loadhook(lambda: SESSION.transfer(session))
    )

# app.add_processor(web.loadhook())

# 定义WSGI的Application
application = app.wsgifunc()

# 启动App
if __name__ == '__main__':
    web.config.debug = CONFIGS.DEBUG
    HttpFrame().start_server()
    app.run()
